1
|
|
|
function pre_process_data(data) { |
2
|
|
|
var product_cache = {}; |
3
|
|
|
var tags_cache = {}; |
4
|
|
|
|
5
|
|
|
data.forEach(function(element) { |
6
|
|
|
// collect info about products |
7
|
|
|
addResourceToData(element, 'tag', 'Tag.filter', tags_cache); |
8
|
|
|
|
9
|
|
|
if (element.plan_id in product_cache) { |
10
|
|
|
element['product'] = product_cache[element.plan_id]; |
11
|
|
|
} else { |
12
|
|
|
jsonRPC('TestPlan.filter', {pk: element.plan_id}, function(data) { |
13
|
|
|
element['product'] = data[0].product; |
14
|
|
|
}, true); |
15
|
|
|
product_cache[element.plan_id] = element.product; |
16
|
|
|
} |
17
|
|
|
}); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
$(document).ready(function() { |
22
|
|
|
var table = $("#resultsTable").DataTable({ |
23
|
|
|
ajax: function(data, callback, settings) { |
|
|
|
|
24
|
|
|
var params = {}; |
25
|
|
|
|
26
|
|
|
if ($('#id_summary').val()) { |
27
|
|
|
params['summary__icontains'] = $('#id_summary').val(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
if ($('#id_plan').val()) { |
31
|
|
|
params['plan'] = $('#id_plan').val(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if ($('#id_product').val()) { |
35
|
|
|
params['plan__product'] = $('#id_product').val(); |
36
|
|
|
}; |
37
|
|
|
|
38
|
|
|
if ($('#id_version').val()) { |
39
|
|
|
params['product_version'] = $('#id_version').val(); |
40
|
|
|
}; |
41
|
|
|
|
42
|
|
|
if ($('#id_build').val()) { |
43
|
|
|
params['build'] = $('#id_build').val(); |
44
|
|
|
}; |
45
|
|
|
|
46
|
|
|
if ($('#id_manager').val()) { |
47
|
|
|
params['manager__username__startswith'] = $('#id_manager').val(); |
48
|
|
|
}; |
49
|
|
|
|
50
|
|
|
if ($('#id_default_tester').val()) { |
51
|
|
|
params['default_tester__username__startswith'] = $('#id_default_tester').val(); |
52
|
|
|
}; |
53
|
|
|
|
54
|
|
|
updateParamsToSearchTags('#id_tag', params); |
55
|
|
|
|
56
|
|
|
params['stop_date__isnull'] = $('#id_running').is(':checked'); |
57
|
|
|
|
58
|
|
|
dataTableJsonRPC('TestRun.filter', params, callback, pre_process_data); |
59
|
|
|
}, |
60
|
|
|
columns: [ |
61
|
|
|
{ data: "run_id" }, |
62
|
|
|
{ |
63
|
|
|
data: null, |
64
|
|
|
render: function (data, type, full, meta) { |
|
|
|
|
65
|
|
|
result = '<a href="/runs/'+ data.run_id + '/" target="_parent">' + escapeHTML(data.summary) + '</a>'; |
|
|
|
|
66
|
|
|
if (data.stop_date) { |
67
|
|
|
result += '<p class="help-block">' + data.stop_date + '</p>'; |
68
|
|
|
} |
69
|
|
|
return result; |
70
|
|
|
} |
71
|
|
|
}, |
72
|
|
|
{ |
73
|
|
|
data: null, |
74
|
|
|
render: function (data, type, full, meta) { |
|
|
|
|
75
|
|
|
return '<a href="/plan/'+ data.plan_id + '/" target="_parent">TP-' + data.plan_id + ': ' + escapeHTML(data.plan) + '</a>'; |
76
|
|
|
} |
77
|
|
|
}, |
78
|
|
|
{ data: "product" }, |
79
|
|
|
{ data: "product_version"}, |
80
|
|
|
{ data: "build"}, |
81
|
|
|
|
82
|
|
|
{ data: "manager" }, |
83
|
|
|
{ data: "default_tester" }, |
84
|
|
|
{ |
85
|
|
|
data: "tag", |
86
|
|
|
render: renderFromCache, |
|
|
|
|
87
|
|
|
}, |
88
|
|
|
], |
89
|
|
|
dom: "t", |
90
|
|
|
language: { |
91
|
|
|
loadingRecords: '<div class="spinner spinner-lg"></div>', |
92
|
|
|
processing: '<div class="spinner spinner-lg"></div>', |
93
|
|
|
zeroRecords: "No records found" |
94
|
|
|
}, |
95
|
|
|
order: [[ 0, 'asc' ]], |
96
|
|
|
}); |
97
|
|
|
|
98
|
|
|
hookIntoPagination('#resultsTable', table); |
99
|
|
|
|
100
|
|
|
$('#btn_search').click(function() { |
101
|
|
|
table.ajax.reload(); |
102
|
|
|
return false; // so we don't actually send the form |
103
|
|
|
}); |
104
|
|
|
|
105
|
|
|
$('#id_product').change(function() { |
106
|
|
|
update_version_select_from_product(); |
107
|
|
|
update_build_select_from_product(true); |
108
|
|
|
}); |
109
|
|
|
|
110
|
|
|
$('.bootstrap-switch').bootstrapSwitch(); |
111
|
|
|
|
112
|
|
|
$('.selectpicker').selectpicker(); |
113
|
|
|
}); |
114
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.